## FocusCommon.py - A set of common classes and functions for MyFocus
## Copyright (C) January 26, 2005 Erick P. Bodine
## email: erick_bodine@comcast.net
## webaddress

## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or any later version.

## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


"""
NAME
FocusCommon

DESCRIPTION
A collection of common classes and functions for use by wxfocus

AUTHOR
Erick P Bodine
"""


import os
import sys

__author__ = "$Author: ebodine $"
__date__ = "$Date: 2005-03-13 21:20:46 -0700 (Sun, 13 Mar 2005) $"
__version__ = "$Revision: 7 $"

OPERATING_SYSTEM = sys.platform


def openFileInEditor(file_):
    try:
        EDITOR = os.environ['EDITOR']
    except KeyError:
        EDITOR = None

    if not EDITOR:
        if OPERATING_SYSTEM == 'win32':
            EDITOR_STR = 'notepad.exe '+file_
        else:
            EDITOR_STR = 'vi '+file_
    else:
        EDITOR_STR = EDITOR+' '+file_

    if os.system(EDITOR_STR) != 0:
        print "CRITICAL: Unable to run (%s)" % EDITOR_STR; sys.exit(1)
